package buymyhome.com.service.impl;

import buymyhome.com.common.Code;
import buymyhome.com.dao.LetHouseDao;
import buymyhome.com.pojo.LetHouse;
import buymyhome.com.pojo.UsedHouse;
import buymyhome.com.service.LetHouseService;
import buymyhome.com.vojo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 杨世博
 */
@Service
public class LetHouseServiceImpl extends ServiceImpl<LetHouseDao, LetHouse> implements LetHouseService {
    @Resource
    private LetHouseDao letHouseDao;

    @Override
    public Result getAdminLetHouse(String name, Integer page, Integer limit) {
        QueryWrapper<LetHouse> qw = new QueryWrapper<>();
        IPage<LetHouse> p = new Page(page, limit);

        qw.eq(name!=null&& !"".equals(name),"name",name);
        letHouseDao.selectPage(p, qw);

        return new Result(p, Code.INQUIRE_OK);
    }

    @Override
    public Result delLetHouse(Long id) {
        letHouseDao.deleteById(id);
        return new Result(null, Code.OPERATE_OK);
    }
}
